package com.dingqb.mycs.ui.activity;

import java.util.HashMap;
import java.util.Map;

import android.os.Bundle;

import com.android.volley.Request.Method;
import com.android.volley.Response;
import com.android.volley.Response.Listener;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.base.AppApplication;
import com.base.datacallback.VolleyCallBackListener;

public class VolleryTask {
	static VolleyCallBackListener mListener;

	public static void getVollery(VolleyCallBackListener listener, String tag, String url, final Bundle bundle) {
		mListener = listener;

		StringRequest request = new StringRequest(Method.GET, url, new Listener<String>() {

			@Override
			public void onResponse(String response) {
				mListener.onSuccess(response, bundle);
			}
		}, new Response.ErrorListener() {

			@Override
			public void onErrorResponse(VolleyError error) {

				mListener.onFailure(error, bundle);
			}
		});
		request.setTag(tag);
		AppApplication.getHttpQueue().add(request);

	}

	public static void getVolleryHistory(VolleyCallBackListener listener, String tag, String url, final HashMap<String, String> map,
			final Bundle bundle) {
		mListener = listener;

		StringRequest request = new StringRequest(Method.POST, url, new Listener<String>() {

			@Override
			public void onResponse(String response) {
				mListener.onSuccess(response, bundle);
			}
		}, new Response.ErrorListener() {

			@Override
			public void onErrorResponse(VolleyError error) {

				mListener.onFailure(error, bundle);
			}
		}) {
			@Override
			protected Map<String, String> getParams() {
				// 在这里设置需要post的参数
				return map;
			}
		};
		request.setTag(tag);
		AppApplication.getHttpQueue().add(request);

	}


}
